package Operation;

import Book.BookList;

import java.util.Scanner;

public class FindBook implements IOPeration{
    @Override
    public void work(BookList books) {
        System.out.println("查找图书.....");
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入要查找的图书：");
        String name = sc.nextLine();

        int currentSize = books.getUsedSize();
        for (int i = 0; i < currentSize; i++) {
            if(books.getBook(i).getName().equals(name)) {
                System.out.println("找到了，信息如下：");
                System.out.println(books.getBook(i));
                return;
            }
        }
        System.out.println("没有找到。");
    }
}
